package com.lqk.fnandroid.viewmodel

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.FragmentActivity
import com.lqk.fnandroid.databinding.ActivityViewModelBinding

class ViewModelActivity : FragmentActivity() {

    lateinit var binding: ActivityViewModelBinding

    lateinit var vm: MainViewModel

    fun initState() {

    }

    fun showLoading() {

    }

    fun initListener() {
        binding.tvTestGet.setOnClickListener {
            showLoading()
            vm.doGet()
        }
        binding.tvTestPost.setOnClickListener {
            showLoading()
            vm.doPost()
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityViewModelBinding.inflate(layoutInflater)
        setContentView(binding.root)
        vm = MainViewModel()
        binding.lifecycleOwner = this
        binding.vm = vm
        initState()
        initListener()
    }
}